﻿ //20.Write a program that reads two numbers N and K and generates all the variations of K elements from the set [1..N].
 //Example: N = 3, K = 2  -> {1, 1}, {1, 2}, {1, 3}, {2, 1}, {2, 2}, {2, 3}, {3, 1}, {3, 2}, {3, 3}
 
 
using System;
using System.Collections.Generic;

class Variations
{
    static void Main()
    {
        int numberN = int.Parse(Console.ReadLine());
        int numberK = int.Parse(Console.ReadLine());
        int[] arrK = new int[numberK];
        VariationsCalc(arrK, numberK - 1, numberN);
    }
    static void VariationsCalc(int[] arrK, int index, int numberN)
    {
        if (index == -1)
        {
            Print(arrK);
        }
        else
        {
            for (int i = 1; i <= numberN; i++)
            {
                arrK[index] = i;
                VariationsCalc(arrK, index - 1, numberN);
            }
        }
    }
    static void Print(int[] arrK)
    {
        foreach (var num in arrK)
        {
            Console.Write(num);
        }
        Console.WriteLine();
    }
}
